import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
const BASE_API = '/api'

export default defineConfig({
  server: {
    port: 9999,
    open: true,
    cors: true,
    host: '0.0.0.0',
    proxy: {
      [BASE_API]: {
        // target: `https://test-k8s-puhyun-gateway.peogoo.com`,
        target: 'http://10.20.39.103:3000',
        changeOrigin: true,
        secure: false,
        rewrite: path => path.replace(/^\/api/, '')
      }
    }
  },
  resolve: {
    alias: {
      '~': resolve(__dirname, './'),
      '@': resolve(__dirname, 'src')
    }
  },
  plugins: [
    vue(),
    Components({
      resolvers: [ElementPlusResolver()]
    })
  ]
})
